package org.dromara.common.model.enums.groupuser;

/**
 * 群成员权限
 * @author Stars
 */

public enum GroupMemberPermissionEnum {
    GROUP_OWNER("GroupOwner", "群主"),
    ADMINISTRATOR("Administrator", "管理员"),
    REGULAR_MEMBER("RegularMember", "普通群成员");

    private final String code;
    private final String description;

    GroupMemberPermissionEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据权限代码获取对应的权限描述
     * @param code 权限代码
     * @return 对应的权限描述，如果未找到则返回 null
     */
    public static String getDescriptionByCode(String code) {
        for (GroupMemberPermissionEnum permission : values()) {
            if (permission.getCode().equals(code)) {
                return permission.getDescription();
            }
        }
        return null;
    }
}
